#!/usr/bin/env python

import os
import sys

import beancount.ingest.extract

isSmart = True
try:
    from smart_importer import apply_hooks, PredictPostings
    from smart_importer.detector import DuplicateDetector
    import jieba
    jieba.initialize()
    tokenizer = lambda s: list(jieba.cut(s))

except ImportError:
    isSmart = False


beancount.ingest.extract.HEADER = ''
sys.path.append("./")
from importers.cmb_json import CmbJSONImporter

account = 'Liabilities:CreditCards:CMB:Card'

if isSmart:
    CONFIG = [
        apply_hooks(CmbJSONImporter(account=account), [
                    DuplicateDetector(), PredictPostings(string_tokenizer=tokenizer)])
    ]
else:
    CONFIG = [
        CmbJSONImporter(account=account)
    ]
